package com.ourhours.message.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * Description:SupplierAccountEnum 供应商类型枚举.
 *
 * @author chi.chen
 * @version V1.0
 * @since 2018/3/29
 */
public enum SupplierTypeEnum {

    SMS_HUAXIN(11, "华信短信"),//短信供应商：华信。
    EMAIL_APACHE(21, "邮件组件"),//发邮件阿帕奇组件。
    APP_PUSH_JPUSH(31, "极光推送");//app推送供应商：极光推送。


    private int code;
    private String content;

    private SupplierTypeEnum(Integer code, String content) {
        this.code = code;
        this.content = content;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public static SupplierTypeEnum fromCode(Integer type) {
        if (null == type) {
            return null;
        }
        for (SupplierTypeEnum supplierTypeEnum : values()) {
            if (type == supplierTypeEnum.getCode()) {
                return supplierTypeEnum;
            }
        }
        return null;
    }

    public static SupplierTypeEnum[] getSupplierTypeEnumValuesByMessageTypeEnum(int messageType) {
        List<SupplierTypeEnum> list = new ArrayList<>();
        for (SupplierTypeEnum one : values()) {
            if ((one.getCode() / 10) == messageType) {
                list.add(one);
            }
        }
        return list.toArray(new SupplierTypeEnum[list.size()]);
    }
}
